﻿// =================================================================== 
// 项目说明
//====================================================================
// lcx @Copy Right 2019
// 文件： GovUserCitiesRelRepository.cs
// 项目名称：斑马车务
// 创建时间：2019/1/16
// 负责人：lcx
// ===================================================================

using CGT.Infrastructure.Entity;
using Dapper;
using System.Collections.Generic;

namespace CGT.Infrastructure.Repository
{
    /// <summary>
    /// 仓储层
    /// </summary>	
    public class GovUserCitiesRelRepository : BaseRepository<GovUserCitiesRel>
    {

        #region 构造

        public GovUserCitiesRelRepository() : base() { }

        public GovUserCitiesRelRepository(string connectionString) : base(connectionString) { }

        public GovUserCitiesRelRepository(DatabaseContext dbContext) : base(dbContext) { }

        #endregion

        /// <summary>
        /// 根据用户Id获取配置城市信息
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public List<GovUserCitiesRel> GetByUserId(int userId)
        {
            string sql = "select * FROM GovUserCitiesRel WHERE UserId =@UserId ";
            DynamicParameters dparams = new DynamicParameters();
            dparams.Add("@UserId", userId, System.Data.DbType.Int32);
            return base.QueryList(1, 1000, sql, dparams);
        }

        /// <summary>
        /// 根据UserId批量删除
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public void BatchDeleteByUserId(int userId)
        {
            string sql = "delete   FROM GovUserCitiesRel WHERE UserId =@UserId ";
            DynamicParameters dparams = new DynamicParameters();
            dparams.Add("@UserId", userId, System.Data.DbType.Int32);
            base.Execute(sql, dparams);
        }
    }
}